
load("Effects_of_Polls.RData")

# The visualizations below requires the "jtools" library
library(jtools)

# Create new numeric group variable 
mturk$Group <- 0
mturk$Group[mturk$group=="treatment"] <- 1

###############################
# guest worker
###############################

m1 <- lm(composite~Group, data=subset(mturk, issue=="IMM"))
m2 <- lm(composite~Group*closeness.dem, data=subset(mturk, issue=="IMM"))
m4 <- lm(composite~Group*closeness.dem + age + education + interest + partyid, data=subset(mturk, issue=="IMM"))

interact_plot(m4, modx = Group, pred = closeness.dem, interval = TRUE, int.type = "confidence", int.width = .90, color.class = "Greys", y.lab="Support for Issue", x.lab="Feel Close to Dems", modx.labels = c("Control", "Treatment"), main.title="Guest Workers")


###############################
# social security 
###############################

s1 <- lm(composite~Group, data=subset(mturk, issue=="SOC"))
s3 <- lm(composite~Group*age, data=subset(mturk, issue=="SOC"))
s5 <- lm(composite~Group*age + education + interest + partyid, data=subset(mturk, issue=="SOC"))

interact_plot(s5, modx = Group, pred = age, interval = TRUE, int.type = "confidence", int.width = .90, color.class = "Greys", y.lab="Support for Issue", x.lab="Age", modx.labels = c("Control", "Treatment"), main.title="Social Security")



###############################
# vaccines
###############################

v1 <- lm(composite~Group, data=subset(mturk, issue=="VAC"))
v2 <- lm(composite~Group*closeness.parents, data=subset(mturk, issue=="VAC"))
v4 <- lm(composite~Group*closeness.parents + age + education + interest + partyid, data=subset(mturk, issue=="VAC"))

interact_plot(v4, modx = Group, pred = closeness.parents, interval = TRUE, int.type = "confidence", int.width = .90, color.class = "Greys", y.lab="Support for Issue", x.lab="Feel Close to Parents", modx.labels = c("Control", "Treatment"), main.title="School Vaccines")

